import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay

# 定义点集：起点、终点和一些拓扑点（避开）
points = np.array(
    [
        [-2, 1],
        [1, -2],
        [1, 2],
        [2, 3],
        [3, 1],
        [4, 2],
        [4, 7],
        [7, 4],
    ]
)

start = [0, 0]
end = [5, 5]

# Delaunay三角剖分
tri = Delaunay(points)

# 可视化
plt.triplot(points[:, 0], points[:, 1], tri.simplices)
plt.plot(points[:, 0], points[:, 1], "o")

# 起点和终点
plt.plot(start[0], start[1], "ro")
plt.plot(end[0], end[1], "ro")

plt.show()
